#include <func.h>

void sigfunc(int signum,siginfo_t *p,void* p1)
{
    printf("before sleep,sig %d is coming\n",signum);
    sleep(3);
    printf("after sleep,sig %d is coming\n",signum);
}
int main()
{
    struct sigaction act;//一定要清空
    bzero(&act,sizeof(act));
    act.sa_sigaction=sigfunc;//把信号处理函数赋给sa_sigaction
    act.sa_flags=SA_SIGINFO|SA_NODEFER;//SA_SIGINFO加上后，sa_sigaction信号处理函数生效
    int ret=sigaction(SIGINT,&act,NULL);//act是传入参数
    ERROR_CHECK(ret,-1,"sigaction")
    bzero(&act,sizeof(act));
    act.sa_sigaction=sigfunc;
    act.sa_flags=SA_SIGINFO|SA_NODEFER;
    ret=sigaction(SIGQUIT,&act,NULL);
    ERROR_CHECK(ret,-1,"sigaction")
    while(1);
    // char buf[100]={0};
    // ret=read(STDIN_FILENO,buf,sizeof(buf));//read读标准输入
    // printf("ret=%d,buf=%s",ret,buf);
    return 0; 
}